#include"server.hpp"


void OnDisConnect(const SharedptrCon& con)
{
    DBG_LOG("RELEASE CONNECTION: %p",con.get());
}

void OnConnect(const SharedptrCon& con)
{
    DBG_LOG("CONNECTION CREATE SUCCESS!!");
}

void OnMessage(const SharedptrCon& con,Buffer* buf)
{
    char buffer[65535];
    buf->ReadAndPop(buffer,buf->ReadableSize());
    DBG_LOG("%s",buffer);
    std::string ret = "这是一个处理结果";
    con->Send(ret.c_str(),ret.size());
}


int main()
{
    TcpServer svr(8888);
    svr.SetThreadCount(2);
    svr.EnableInactiveRelease(10);
    svr.SetConnectCallback(OnConnect);
    svr.SetMessagetCallback(OnMessage);
    svr.SetDisconnectCallback(OnDisConnect);
    svr.Start();
}